package com.bayihouse.model.vo;

import com.bayihouse.model.entity.Announcement;
import com.bayihouse.utils.MyDateUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;


@AllArgsConstructor
@NoArgsConstructor
@Data
@ToString
public class AnnouncementDetailVO implements Serializable {
    private static final long serialVersionUID = -220533068579837659L;


    /**
     * 公告Id
     */
    private Long id;

    /**
     * 公告内容
     */
    private String content;

    /**
     * 上传者电话
     */
    private String telephone;

    /**
     * 创建时间
     */
    private String createtime;

    /**
     * 上传者Id
     */
    private String administerName;

    /**
     * 作者名字
     */
    private String authername;

    /**
     * 公告题目
     */
    private String title;


    /**
     * 附件
     */
    private List<FileVO> otherFiles;

    /**
     * 每个公告都有自己的图片
     */
    private String headimageUrl;

    public static AnnouncementDetailVO objToVo(Announcement anncouncement) {
        AnnouncementDetailVO announcementDetailVO = new AnnouncementDetailVO();
        BeanUtils.copyProperties(anncouncement, announcementDetailVO);
        announcementDetailVO.setCreatetime(MyDateUtils.dateToString(anncouncement.getCreatetime()));
        return announcementDetailVO;
    }
}
